package com.groupseven.happycampus.controller;

import com.groupseven.happycampus.common.pojo.Commodity;
import com.groupseven.happycampus.common.result.R;
import com.groupseven.happycampus.service.CommodityService;
import org.codehaus.jettison.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/commodityTransaction")
public class CommodityTransactionController {

    @Autowired
    private CommodityService commodityService;


    /**
     *  购买 宝贝的方法
     * @param commodity 购入的宝贝
     * @return 返回购买结构
     */
    @RequestMapping("/purchase")
    public R commodityTransaction(Commodity commodity){
        System.out.println(commodity);
        return commodityService.purchasedCommodity(commodity);

    }
    @RequestMapping("/putOnTheShelfByIds")
    public R commodityTransactionByIds(String ids){// 1,2
        System.out.println(ids);
        //  通过 id 获取 商品的信息 从而通过 商品 id 获取商品
        return commodityService.purchasedCommodityByIds(ids);


    }

}
